#include "Scene/SceneObject.h"

namespace vital {

	//--------------------------------------------------------------------------
	TSceneObject::TSceneObject(IRenderable *renderable, IShader *shader) {

		mShader = shader;
		mRenderable = renderable;
		mVisFlags = 0xffffff;
	}

	//--------------------------------------------------------------------------
	TSceneObject::~TSceneObject() {

		delete mShader;
		delete mRenderable;
	}

	//--------------------------------------------------------------------------
	IShader * TSceneObject::getShader() {

		return mShader;
	}

	//--------------------------------------------------------------------------
	void TSceneObject::render() {

		// render
		size_t passCnt = mShader->beginRender();

		for(size_t i=0; i<passCnt; ++i) {

			mShader->beginPass(i);

			mRenderable->render();

			mShader->endPass();
		}

		mShader->endRender();
	}

	//--------------------------------------------------------------------------
	unsigned long TSceneObject::getVisFlags() {

		return mVisFlags;
	}

	//--------------------------------------------------------------------------
	void TSceneObject::setVisFlags(unsigned long flags) {

		mVisFlags = flags;
	}

	//--------------------------------------------------------------------------
	bool TSceneObject::isVisible(unsigned long mask) {

		return (mVisFlags & mask) != 0;
	}

	//--------------------------------------------------------------------------

}